package sg.edu.nus.comp.icreate.ivletalk;

import sg.edu.nus.comp.icreate.ivletalk.module.MainActivity;
import sg.edu.nus.comp.icreate.ivletalk.utils.LoginWebViewClient;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;

public class LoginActivity extends Activity {
	public static String LOGINURL = "https://ivle.nus.edu.sg/api/login/?apikey=" + MainActivity.APIKEY + "&url=blank";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
		setContentView(R.layout.activity_login);
		WebView web = (WebView) findViewById(R.id.loginWebView);
		web.loadUrl(LOGINURL);
		web.setWebViewClient(new LoginWebViewClient(this));
	}

	public void loginSuccess() {
		Intent intent = new Intent(this, MainActivity.class);
		intent.putExtra(BaseActivity.EXTRA_NEED_REFRESH, true);
		startActivity(intent);
		finish();
	}

}
